package com.jinmdz.fmis.api.api.controller;

import com.jinmdz.fmis.api.api.service.DictionaryService;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import com.jinmdz.fmis.dao.model.dictionary.DataDictionaryItem;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * 字典管理相关接口
 *
 * @author LiCongLu
 * @date 2020-01-13 10:27
 */
@Api(description = "字典管理相关接口")
@RestController()
@RequestMapping("/api/dictionary")
public class DictionaryController extends BaseController {

    @Resource
    private DictionaryService dictionaryService;

    /**
     * 获取字典数据接口
     *
     * @param data 字典类型数据
     * @return
     * @author LiCongLu
     * @date 2020-01-13 12:03
     */
    @ApiOperation(value = "根据字典编码加载字典值，多个字典编码可用英文逗号分隔"
            , notes = "字典编码：性别代码[sex] ，性别代码(简单,只含男女)[sex_simple]，年龄类型[age_type]，证件类型[certificates]" +
            "，国籍[nationality] ，户籍[domicile] " +
            "，民族[nation] ，逝者类型[type_of_death] ，火化类型[cremation_type] ，遗体状态[remains_state]，死亡原因[cause_of_death]" +
            "，惠民区域[huimin_region] ，减免类型（遗体分类）[exemption_type] " +
            "，接运方式[mode_with_carry] ，与逝者关系[relationship_with_deceased] ，殡葬单位类型[funeral_unit_type]" +
            "，承办人类型[agent_type],车辆类型[transport_car_type]，车辆用途[transport_car_use]，车辆归属【car_belong】" +
            "，接运任务状态[transport_car_task_status]，冷藏柜类型[equipment_type],冷藏状态[refrigerated_state]" +
            "，礼厅业务类型[hall_business_type]，礼厅状态[hall_status],礼厅类型[hall_type],火化炉类型[furnace_type]" +
            "，火化任务状态[cremation_task_status]，骨灰去向[ashes_whereabouts]" +
            "，骨灰处理方式[ashes_treatment]，结算付款方式[pay_type]，结算类型[settle_type]" +
            "，火化证打印操作类型[cremation_certificate_printing_operation_type]，文档类型[document_type]" +
            "，死亡证明出具单位[funeral_certificate_unit]，机构类型[organization_type]，角色分类[role_type]")
    @PostMapping("/load-dictionary")
    public BaseResult<HashMap<String, ArrayList<DataDictionaryItem>>> loadDictionary(@RequestBody ArrayList<String> data) {
        return resultHandler(userItem -> dictionaryService.loadDictionary(data));
    }
}
